<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<div class="menu_top">
	<input type="hidden" name="action" value="list_exe" />
    <input type="hidden" id="autorun_0" name="autorun_0" value="0" />
    <input type="hidden" id="autorun_1" name="autorun_1" value="0" />
	<img title="<?php echo ucfirst($txt->getWord('save')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>filesave_22.gif" onclick="edit_form.submit();"  />
</div>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<thead class="fields">
        <tr>
            <th class="first center">&nbsp;&nbsp;#&nbsp;&nbsp;</th>
            <th><?php echo ucfirst($txt->getWord('title')); ?></th>
            <th><?php echo ucfirst($txt->getWord('type')); ?></th>
            <th><?php echo ucfirst($txt->getWord('autorun')); ?></th>
            <th><?php echo ucfirst($txt->getWord('frequency')); ?></th>
            <th><?php echo ucfirst($txt->getWord('timeset')); ?></th>
            <th><?php echo ucfirst($txt->getWord('lastrun')); ?></th>
            <th><?php echo ucfirst($txt->getWord('active')); ?></th>
            <th><?php echo ucfirst($txt->getWord('edit')); ?></th>
            <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
        </tr>
    </thead>
    <tbody>
        <tr class="items">
            <td class="first center">0</td>
            <td><input class="xsmall" id="new_exe" name="new_exe[]" type="text" value="" maxlength="50" /></td>
            <td class="last">
            	<select class="small" name="new_exe_type[]" onchange="submit();">
                    <option value="0" <?php echo getIsSelectedHTML($exe['effect'], 0); ?>>
						<?php echo ucfirst($txt->getWord('product')).' '.ucfirst($txt->getWord('import')); ?>
                    </option>
                    <option value="1" <?php echo getIsSelectedHTML($exe['type'], 1); ?>>
						<?php echo ucfirst($txt->getWord('product')).' '.ucfirst($txt->getWord('images')); ?>
                    </option>
                </select>
            </td>
            <td colspan="5">&nbsp;</td>
            <td class="center">
            	<img 
                	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                    class="icon command" 
                    src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                    onclick="if(document.getElementById('new_exe').value != '') { edit_form.submit(); }" />
            </td>
            <td class="last">&nbsp;</td>
        </tr>
        <?php 
        if($exes):
        foreach($exes as $exe)
        {
			if(((is_numeric($_GET['type'])) && ($exe['type'] == $_GET['type'])) || (!(is_numeric($_GET['type']))))
			{
			?>
			<tr class="items">
				<td class="first center"><?php echo $exe['id']; ?><input type="hidden" name="exe_id[]" value="<?php echo $exe['id']; ?>" /></td>
				<td>
					<input class="xsmall" name="exe_title[]" type="text" value="<?php echo $exe['title']; ?>" maxlength="50" />
				</td>
				<td>
					<select class="small" name="exe_type[]" onchange="submit();">
						<option value="0" <?php echo getIsSelectedHTML($exe['type'], 0); ?>>
							<?php echo ucfirst($txt->getWord('product')).' '.ucfirst($txt->getWord('import')); ?>
						</option>
						<option value="1" <?php echo getIsSelectedHTML($exe['type'], 1); ?>>
							<?php echo ucfirst($txt->getWord('product')).' '.ucfirst($txt->getWord('images')); ?>
						</option>
					</select>
				</td>
				<td class="center"><?php echo $commander->getTrueFields($exe, 'autorun_1', 'autorun_0', 'autorun', 1); ?></td>
				<td>
					<select class="small" name="exe_frequency[]" onchange="submit();" <?php echo getIsDisabledHTML($exe['autorun'] != 0); ?>>
						<option value="0" <?php echo getIsSelectedHTML($exe['frequency'], 0); ?>><?php echo ucfirst($txt->getWord('daily')); ?></option>
						<option value="1" <?php echo getIsSelectedHTML($exe['frequency'], 1); ?>><?php echo ucfirst($txt->getWord('hourly')); ?></option>
					</select>
				</td>
				<td>
					<select class="xsmall" name="exe_timeset[]" <?php echo getIsDisabledHTML($exe['autorun'] != 0); ?> <?php echo getIsDisabledHTML($exe['frequency'] == 0); ?> onchange="submit();">
						<?php
						for($i=0; $i<24; $i++)
						{
							$text = $i;
							if($i < 10)
							{ $text = '0'.$text; }
							
							echo '<option value="'.$i.'" '.getIsSelectedHTML($exe['timeset'], $i).'>'.$text.':00</option>';
						}
						?>
					</select>
				</td>
				<td>
					<?php 
					if($exe['last_run'] == '0000-00-00 00:00:00')
					{ echo ucfirst($txt->getWord('never')); }
					else
					{ echo substr($exe['last_run'], 0, 16); }
					?>
				</td>
				<td class="center">
					<?php echo $commander->getActivationFields($exe); ?>
					<input type="hidden" name="exe_active[]" value="<?php echo $exe['active']; ?>" />
				</td>
				<td class="center">
					<a href="?con=<?php echo $_REQUEST['con']; ?>&exe=<?php echo $exe['id']; ?>"><img title="<?php echo ucfirst($txt->getWord('edit')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>configure_16.gif" onclick="edit_form.submit();"  /></a>
				</td>
				<td class="last center">
					<input title="<?php echo ucfirst($txt->getWord('delete')); ?>" class="inp_image" type="image" name="delete_exe" src="<?php echo SYSICONS_URL; ?>delete_16.gif" value="0" onclick="this.value='<?php echo $exe['id']; ?>'; edit_form.submit();" />
				</td>
			</tr>
			<?php
			}
        }
        endif; 
        ?>
	</tbody>
</table>
</div>